package web;


import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zhuozhengsoft.pageoffice.FileSaver;
import com.zhuozhengsoft.pageoffice.OpenModeType;
import com.zhuozhengsoft.pageoffice.PageOfficeCtrl;

@Controller
public class SaveAsPDF extends HttpServlet{
	private static final long serialVersionUID = -758686623642845302L;
	
	@RequestMapping("saveAsPDF")
	public String saveAsPDF(HttpServletRequest request, HttpServletResponse response){
		PageOfficeCtrl pocCtrl=new PageOfficeCtrl(request);
		//设置服务器页面
		pocCtrl.setServerPage(request.getContextPath()+"/poserver.zz");
		//添加自定义按钮
		pocCtrl.addCustomToolButton("保存", "Save()", 1);
		pocCtrl.addCustomToolButton("另存为PDF文件", "SaveAsPDF()", 1);
		//设置保存页面
		pocCtrl.setSaveFilePage("savefile.do");
		String fileName = "template.doc";
		String pdfName = fileName.substring(0, fileName.length() - 4) + ".pdf";
		request.setAttribute("pdfName", pdfName);
		//打开文件
		pocCtrl.webOpen("doc/" + fileName, OpenModeType.docNormalEdit, "张佚名");
		pocCtrl.setTagId("PageOfficeCtrl1");
		return "WordToPDF";
	}
}
